<template>
  <div>
    testststst
    <el-button size="small" type="primary" @click="testFun">查看</el-button>
  </div>
</template>

<script lang='ts'>
import { defineComponent, Events, ref, computed, watch, reactive } from 'vue'
import { ElMessage } from 'element-plus'
import { UploadFile } from 'node_modules/element-plus/lib/el-upload/src/upload.type'
export default defineComponent({
  name: 'Test',
  components: {
  },
  props: {
    test: {
      type: String,
      require: false
    }
  },
  setup () {
    // 获取当前vue实例
    // const instance = getCurrentInstance()
    const onClick = () => {
      ElMessage('test')
    }
    const obj1 = reactive({
      name: 'leisuchu'
    })
    const showCut = ref(false)
    const imgsrc = ref('')
    const fileList = ref([])
    const name = computed(() => obj1.name)
    const fileChange = (e: UploadFile) => {
      console.log(e)
      if (!e.url) return
      showCut.value = true
      imgsrc.value = e.url
    }
    const handlePreview = (e: Events) => {
      console.log(e)
    }
    const handleRemove = (e: Events) => {
      console.log(e)
    }
    watch(name, (newVal) => {
      console.log('newVal: ', newVal)
    })
    const testFun = () => {
      obj1.name += 1
    }
    return {
      onClick,
      handlePreview,
      handleRemove,
      fileList,
      fileChange,
      showCut,
      imgsrc,
      testFun
    }
  }
})
</script>

 <style>
</style>
